﻿using Database.Context;
using QuanLyThongTinCoSo.BaseForm;
using QuanLyThongTinCoSo.Biz;
using QuanLyThongTinCoSo.Common;
using Model = Database.Models;

namespace QuanLyThongTinCoSo.Forms.Phong
{
    public partial class FrmPhongDisplay : frmObject
    {
        private void LoadForm()
        {
            InitializeComponent();
            lblSo.Text = Constant.SoDetail.TenSo;
            this.ControlBox = true;
            dgvDoi.AutoGenerateColumns = false;
        }

        public FrmPhongDisplay(int id)
        {
            LoadForm();
            Text = @"Thông tin phòng";

            var context = new Context();
            var phongBiz = new PhongBiz(context);
            var doiBiz = new DoiBiz(context);

            var model = phongBiz.GetItemById(id) as Model.Phong;

            if (model == null) return;
            txtTenPhong.Text = model.TenPhong;
            txtDienGiai.Text = model.DienGiai;

            dgvDoi.DataSource = null;
            dgvDoi.Refresh();
            dgvDoi.DataSource = doiBiz.GetAllDoiByPhongId(model.Id);
        }
    }
}